#pragma once
#include <boost/asio.hpp>
#include <iostream>
#include <string>
#include <boost/thread.hpp>

class TCPClient
{
public:
    TCPClient(const std::string& address ,short port):io(),socket(io)
    {
        boost::asio::ip::tcp::resolver resolver(io);
        boost::asio::ip::tcp::resolver::results_type endpoint = resolver.resolve(address, std::to_string(port));
        boost::asio::async_connect(socket, endpoint);
        startReceive();
    }

    void startReceive();
    void send(const std::string& mes);
private:
    boost::asio::io_context io;
    boost::asio::ip::tcp::socket socket;
    boost::asio::streambuf receivebuffer;
};